package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonTeacherListClassDataBean;
import com.fancy.learncenter.bean.CartoonTeacherWorkListDataBean;
import com.fancy.learncenter.common.JumpIntentKey;
import com.fancy.learncenter.ui.activity.CartoonTeacherReportDetailActivity;
import com.fancy.learncenter.ui.activity.CartoonWorkReportActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;

import java.util.List;

/**
 * Created by hyy on 2018/1/24.
 * describe as
 */

public class CartoonTeacherClassDetailAdapter extends CommonRecycleViewAdapter<CartoonTeacherWorkListDataBean.ResultBean> {
    String classId;
    String className;

    public CartoonTeacherClassDetailAdapter(Context mContext, List<CartoonTeacherWorkListDataBean.ResultBean> itemDatas, String classId,String className) {
        super(mContext, R.layout.activity_cartoon_teacher_class_detail_item, itemDatas);
        this.classId = classId;
        this.className = className;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final CartoonTeacherWorkListDataBean.ResultBean item, int position) {

        TextView complete = customViewHold.getView(R.id.complete);
        complete.setText(item.getCommitCount());

        TextView total = customViewHold.getView(R.id.total);
        total.setText("/" + item.getTotalCount());

        TextView status = customViewHold.getView(R.id.status);
        status.setText(item.getHomeworkPackageName());

        TextView lesson_name = customViewHold.getView(R.id.lesson_name);
        lesson_name.setText(item.getLessonName());

        TextView unitName = customViewHold.getView(R.id.unit_name);
        unitName.setText(item.getUnitName());

        TextView time = customViewHold.getView(R.id.time);
        time.setText(item.getEndTime());


        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, CartoonTeacherReportDetailActivity.class);
                intent.putExtra(JumpIntentKey.UNIT_NAME, item.getUnitName());
                intent.putExtra(JumpIntentKey.LESSON_NAME, item.getLessonName());
                intent.putExtra(JumpIntentKey.HOMEWORK_PACKAGE_ID, item.getHomeworkPackageId());
                intent.putExtra(JumpIntentKey.WEEKNUM, item.getWeekNum());
                intent.putExtra(JumpIntentKey.HOME_PACKAGE_NAME, item.getHomeworkPackageName());
                intent.putExtra(JumpIntentKey.CLASSID, classId);

                intent.putExtra(JumpIntentKey.TOTAL_NUM, item.getTotalCount());

                intent.putExtra(JumpIntentKey.COMMIT_NUM, item.getCommitCount());


                intent.putExtra(JumpIntentKey.TIME_NUM, item.getEndTime());

                intent.putExtra(JumpIntentKey.CLASSNAME, className);

                mContext.startActivity(intent);

            }
        });
    }
}
